import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva';
import { message } from 'antd';
import { PrimaryC, PrimaryGhostC, FixedButtonC } from '../../../comps';
import ValuateAnalysisInfo from './valuateAnalysisInfo';

@connect(({ loading, valuationAnalysisM }) => ({
  loading,
  valuationAnalysisM,
  saveLoading: loading.effects['valuationAnalysisM/saveValuateAnalysis'],
}))
export default class ResultSearch extends PureComponent {
  constructor() {
    super();
    this.state = {};
  }
  componentDidMount() {}

  UNSAFE_componentWillReceiveProps(nextProps) {}

  // 确认按钮点击事件
  onOk = () => {
    const { infoDetail } = this.props;
    let params = {
      id: infoDetail?.codeId,
      type: infoDetail.dimension == '1' ? '00' : infoDetail.assetType,
      ...this.analysisInfoRef.getInfo(),
    };
    this.props.dispatch({
      type: 'valuationAnalysisM/saveValuateAnalysis',
      payload: {
        ...params,
      },
      callback: (msg) => {
        if (msg == 'success') {
          this.props.changeResultPage(true, '1');
        }
      },
    });
  };

  render() {
    const {} = this.state;
    const { saveLoading, infoDetail } = this.props;
    return (
      <FixedButtonC
        topHtml={
          <ValuateAnalysisInfo
            id={infoDetail?.codeId}
            dimension={infoDetail?.dimension}
            isStandard={infoDetail?.isStandard}
            type={1} //1新增2详情
            onRef={(ref) => (this.analysisInfoRef = ref)}
          />
        }
        bottomHtml={
          <div style={{ display: 'flex', width: '100%', justifyContent: 'center', height: '50px', alignItems: 'center' }}>
            <PrimaryGhostC
              style={{ margin: '0 10px' }}
              title='取消'
              onClick={() => {
                this.props.changeResultPage(false, '1');
              }}
            />
            <PrimaryC style={{ margin: '0 10px' }} title='确定' onClick={this.onOk} loading={saveLoading} />
          </div>
        }
      />
    );
  }
}
